package com.transport.analysis.traffic;

import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Partitioner;

public class RouteIdPartitioner extends Partitioner<RouteStopPairWritable, IntPairWritable> {
    @Override
    public int getPartition(RouteStopPairWritable key, IntPairWritable value, int numReduceTasks) {
        // Partition by routeId to ensure all records for a given route go to the same
        // reducer
        return (key.getRouteId() & Integer.MAX_VALUE) % numReduceTasks;
    }
}